/*
 * @Author: zhang gen yuan
 * @Date: 2021-09-17 13:56:32
 * @Descripttion: 
 */
import { getPage, remove } from "./../../api/HxUser";
import { reactive } from 'vue'

export function columnsHandler() {
    let data = reactive({
        columns: [
            {
                label: '任务名称',
                prop: 'title',
                type:'input'
            },
            // {
            //     label: '详情说明',
            //     prop: 'info',
            // },
            {
                label: '任务优先级',
                prop: 'taskLevel',
                type: 'template'
            },
            {
                label: '所属项目',
                prop: 'projectId',
                type: 'template',
            },
            {
                label: '预期开始时间',
                prop: 'predictStart',
                type:'date'
            },
            {
                label: '预期结束时间',
                prop: 'predictEnd',
                type:'date'
            },
            // {
            //     label:'实际开始时间',
            //     prop:'startTime',
            // },
            // {
            //     label:'实际结束时间',
            //     prop:'endTime',
            // },
            {
                label: '负责人',
                prop: 'userNames',
                type: 'template',
            },
            {
                label: '状态',
                prop: 'status',
                type: 'template'
            },

        ]
    })
    return data.columns
}

export function taskFunc(drawer) {
    let closeDrawer = () => {
        drawer.value = false
    }
    return {
        closeDrawer
    }
}

//  状态筛选
export function statusFilters(val) {
    let options = [
        {
            label: "规划中",
            value: "0",
        },
        {
            label: "实现中",
            value: "1",
        },
        {
            label: "已实现",
            value: "2",
        },
        {
            label: "拒绝",
            value: "3",
        }
    ];
    return options.find(item => item.value == val).label
};


// 负责人筛选

export function userNamesFilters(val, arr) {
    let strArr = val.split(',')
    let str = '';
    strArr.forEach(item => {
        let obj = arr.find(item1 => item1.id == item)
        if (obj && obj.name) {
            str += obj.name + ','
        }
    })
    return str.slice(0, str.length - 1)
}

export function projectFilter(val,arr){
    let obj = arr.find(item=>item.id == val);
    if(obj?.projectName){
        return obj.projectName
    }
}

// 优先级
export function taskLevelFilters(val) {
    let options = [
        {
            label: '低',
            value: 1
        },
        {
            label: '中',
            value: 2
        },
        {
            label: '高',
            value: 3
        },
    ]
    return options.find(item => item.value == val).label
}


export const statusList = [
    {
        label: '规划中',
        value: '0'
    },
    {
        label: '实现中',
        value: '1'
    },
    {
        label: '已实现',
        value: '2'
    },
    {
        label: '拒绝',
        value: '3'
    },
]

export const levalList = [
    {
        label: '低',
        value: 1,
    },
    {
        label: '中',
        value: 2,
    },
    {
        label: '高',
        value: 3,
    },
]